{extend name="public/base" /}
{block name="container"}
<div class="panel panel-default">
  <div class="panel-heading">
    <h4 class="panel-title">添加用户</h4>
  </div>
  <div class="panel-body panel-body-nopadding">

    <form class="form-horizontal form-bordered" id="submitForm" action="" method="post" >
      <div class="form-group">
        <label class="col-sm-3 control-label">账号:</label>
        <div class="col-sm-6">
          <input type="text" class="form-control" name="username" placeholder="请输入用户名"  value=""  required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label">密码:</label>
        <div class="col-sm-6">
          <input type="password" class="form-control" name="password" placeholder="请输入密码" required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label">确认密码:</label>
        <div class="col-sm-6">
          <input type="password" class="form-control" name="repassword" placeholder="请输入确认密码" required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>真实姓名：</label>
        <div class="col-sm-6">
          <input type="text" class="form-control" placeholder="真实姓名" name="truename" value=""  required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label">性别：</label>
        <div class="col-sm-6 wh-inline">
          <div class="rdio rdio-primary">
            <input type="radio" name="sex" id="sex-1" value="1">男
            <input type="radio" name="sex" id="sex-2" value="2">女
          </div>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>手机号：</label>
        <div class="col-sm-6">
          <input type="text" class="form-control" placeholder="手机号" name="mobile" value=""  required>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>邮箱：</label>
        <div class="col-sm-6">
          <input type="email" class="form-control" placeholder="邮箱" name="email" value="{$data['phone'] ?? ''}">
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label" >所属部门：</label>
        <div class="col-sm-6">
          <select class="form-control" name="group_id"  onchange="getvalue(this.value)" required>
            <option value=""> --请选择部门-- </option>
            {volist name="group" id="vo"}
            <option value="{$vo.id}">{$vo.title}</option>
            {/volist}
          </select>
        </div>
      </div>
       <div class="form-group" id="shop" style="display: none">
        <label class="col-sm-3 control-label">所属店铺：</label>
        <div class="col-sm-6">
          <select class="form-control" name="shop_id">
            <option value=""> --请选择店铺-- </option>
            {volist name="shop" id="vo"}
            <option value="{$vo.id}">{$vo.title}</option>
            {/volist}
          </select>
        </div>
      </div>
      <div class="form-group">
        <label class="col-sm-3 control-label">住址：</label>
        <div class="col-sm-2">
          <select   name="prov" id="province" class="form-control" onchange="getRegion(this.value,1)">
            <option value="-1">--省份--</option>
            {volist name="prov" id="pvo"}
            <option value="{$pvo.code}">{$pvo.name}</option>
            {/volist}
          </select>
        </div>
        <div class="col-sm-2">
          <select  name="city" id="city" class="form-control" onchange="getRegion(this.value,2)">
            <option value="-1">--城市--</option>
          </select>
        </div>
        <div class="col-sm-2">
          <select name="area" id="area" class="form-control">
            <option value="-1">--县/区--</option>
          </select>
        </div>

      </div>

      <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>详细地址：</label>
        <div class="col-sm-6">
          <input class="form-control" type="text" name="address" placeholder="详细地址" datatype="*" value="">
        </div>
      </div>
       <div class="form-group">
        <label class="col-sm-3 control-label"><span>*</span>关联档案：</label>
          <div class="col-sm-6">
          <select class="form-control" name="folder_id" >
            <option value=""> --请选择档案-- </option>
            {volist name="folder" id="vo"}
            <option value="{$vo.id}">{$vo.bumen}--{$vo.name}</option>
            {/volist}
          </select>
        </div>
      </div>
            <div class="form-group">
        <label class="col-sm-3 control-label">状态：</label>
        <div class="col-sm-6 wh-inline">
          <div class="rdio rdio-primary">
            <input type="radio" name="status" id="status-1" value="1">通过
            <input type="radio" name="status" id="status-2" value="0">禁用
          </div>
        </div>
      </div>
      <div class="panel-footer">
       <div class="row">
        <div class="col-sm-6 col-sm-offset-3">
          <input type="hidden" name="id" value="{$data.id ?? ''}">
          <button type="submit" class="btn btn-primary">提交</button>
          <button type="button" class="btn btn-default" onclick="javascript:history.back(-1);">返回</button>
        </div>
      </div>
    </div><!-- panel-footer -->

  </form>
</div>
{/block}
{block name="js"}
<script>
  function getRegion(val,level)
    {
      var $city = $("#city");
      var $area = $("#area");
       if(level=='1'){
                    $city.html('<option value=""> --请选择市-- </option>');
                    $city.val('');
                }
                $area.html('<option value=""> --请选择区-- </option>');
                $area.val('');
      $.post('{:url('index/common/getRegion')}', { pcode: val,level:level}, function(data) {
               var dataObj=eval("("+data+")");//转换为json对象   
               if(dataObj['code']==1){
                if(level=='1'){
                    $.each(dataObj['list'], function(i, item) {
                      $city.append('<option value="'+item['code']+'">'+item['name']+'</option>');
                  });
                }else{
                    $.each(dataObj['list'], function(i, item) {
                      $area.append('<option value="'+item['code']+'">'+item['name']+'</option>');
                  });
                }
            }
        });
  }
</script>
<script>
  function getvalue(id)
  {
    if(id == 5 || id == 4){
      $('#shop').css('display','block');
    }else{
      $('#shop').css('display','none');
    }
  }
</script>
{/block}